package com.gitee.linzl.zuul.gateway.fiters.pre;

import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.REQUEST_URI_KEY;

import java.util.Objects;

import org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper;
import org.springframework.cloud.netflix.zuul.filters.RouteLocator;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.cloud.netflix.zuul.filters.pre.PreDecorationFilter;

import com.netflix.zuul.context.RequestContext;

public class PreDecorationFilterExt extends PreDecorationFilter {

	public PreDecorationFilterExt(RouteLocator routeLocator, String dispatcherServletPath, ZuulProperties properties,
			ProxyRequestHelper proxyRequestHelper) {
		super(routeLocator, dispatcherServletPath, properties, proxyRequestHelper);
	}

	@Override
	public Object run() {
		super.run();
		RequestContext ctx = RequestContext.getCurrentContext();
		if (!Objects.isNull(ctx.get("REQUEST_METHOD_TO_URI_KEY"))) {
			ctx.put(REQUEST_URI_KEY, ctx.get("REQUEST_METHOD_TO_URI_KEY"));
		}
		return null;
	}

}